<template lang="pug">
  .tab-1
    Form(:label-width="90")
      Row(type="flex" justify="start" inline)
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="客户来源：")
            Input(v-model="customerInfo.source" :disabled="isCheck")
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="客户名称：")
            Input(v-model="customerInfo.name" :disabled="isCheck")
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="企业性质：")
            Select(v-model="customerInfo.character" :label-in-value="true"  placeholder="请选择" clearable @on-change="characterChange" :disabled="isCheck")
              Option(v-for="(item, index) in characterArr" :value="item.key" :key="index") {{ item.value }}
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="企业规模：")
            Select(v-model="customerInfo.size" :label-in-value="true"  placeholder="请选择" clearable :disabled="isCheck")
              Option(v-for="(item, index) in sizeArr" :value="parseInt(item.key)" :key="index") {{ item.value }}
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="所属行业：")
            Select(v-model="customerInfo.businessType" :label-in-value="true"  placeholder="请选择" clearable @on-change="businessTypeChange" :disabled="isCheck")
              Option(v-for="(item, index) in customerBusinesstype_arr" :value="item.key" :key="index") {{ item.value }}
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="注册资本：")
            Input(v-model="customerInfo.registerCapital" :disabled="isCheck")
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="客户地址：")
            Input(v-model="customerInfo.address" :disabled="isCheck")
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="客户网址：")
            Input(v-model="customerInfo.webSite" :disabled="isCheck")
        Col(:md="{ span: 24 }" :lg="{ span: 12 }" :xl="{ span: 8 }" :xxl="{span: 6}")
          FormItem(label="公司电话：")
            Input(v-model="customerInfo.phone" :disabled="isCheck")
        Col(span="24")
          FormItem(label="公司简介：")
            Input(v-model="customerInfo.description" type="textarea" :disabled="isCheck")
    .btn.text-center
      Button(v-if="isCheck" type="info" @click="reviseBtn") 修改
      Button(v-else type="info" @click="saveBtn") 保存
</template>

<script>
import HRDCCustomerApi from '@/api/HRDCCustomer.api.js'
export default {
  props: {
    customerBusinesstype_arr: Array,
    sizeArr: Array,
    characterArr: Array,
    customerInfo: Object
  },
  data () {
    return {
      isCheck: true,
      name: '肯哆基'
    }
  },
  methods: {
    reviseBtn () {
      this.isCheck = false
    },
    saveBtn () {
      this.isCheck = true
      HRDCCustomerApi.PostCustomer(this.customerInfo).then(res => {
        if (res.data.success) {
          this.$Message.success(res.data.message)
          this.isCheck = true
        } else {
          
          this.$Message.error({
            content: res.data.message,
            duration: 10,
            closable: true
          })
        }
      })
    },
    // 所属行业选择
    businessTypeChange (val) {
      if (val) {
        this.customerInfo.businessTypeName = val.label
      }
    },
    characterChange (val) {
      if (val) {
        this.customerInfo.characterName = val.label
      }
    }
  }
}
</script>

<style lang="less" scoped>

</style>
